package libaryinterface.interfaceutils;

import libaryinterface.user.UserReturnInterface;
import service.BookRecordService;
import service.impl.BookRecordServiceImpl;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//确定借书时长界面
public class OuttimeInterface  extends JFrame {
    JFrame f1;
    JPanel p1;
    JButton b1,b2;
    JLabel l1;
    public OuttimeInterface(Long recordId, String bookName, Long reutrnNumber, String account)
    {
        Font f = new Font("黑体",Font.PLAIN,30);
        f1 = new JFrame("缴费通知");
        p1=new JPanel();
        b1=new JButton("是");
        b2=new JButton("否");
        l1=new JLabel("该书本已逾期是否缴费？");

        p1.setLayout(null);
        l1.setBounds(120,110,900,60);
        l1.setFont(f);
        b1.setBounds(180,180,80,65);
        b1.setFont(f);
        b2.setFont(f);
        b2.setBounds(300,180,80,65);

        f1.add(p1);
        p1.add(b1);
        p1.add(b2);
        p1.add(l1);

        f1.setVisible(true);
        f1.setBounds(600,250,600,400);

        b1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                BookRecordService bookRecordService = new BookRecordServiceImpl();
                boolean flag = bookRecordService.returnRecord(recordId, bookName, reutrnNumber, account);
                if( flag){
                    f1.dispose();
                    new MyDialogDemo("归还成功!");
                }
            }
        });
        b2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new MyDialogDemo("归还失败，请缴费!!!");
                f1.dispose();
            }
        });
    }

}
